Release 10.1A: OpenEdge Development:
Progress 4GL Handbook
In the beginning…FOR EACH CUSTOMER
There’s a prototypical Progress 4GL procedure often used as an example, one that couldn’t be simpler, but that shows a lot about the power of the language. It has appeared on coffee mugs and tee shirts for two decades. Here it is:
You can’t get much simpler than that, but it would take hours to explain in detail everything that this little procedure does for you. To summarize:
- Customer is the name of a table in the Sports2000 sample database that you’ll connect to in a moment. The
FOR EACHstatement starts a block of code that opens a query on that database table and returns each record in the table, one at a time, in each iteration of the block.- Each Customer record is displayed on the screen in turn. The code takes formatting and label information from the database schema definition and uses it to create a default display format for all the fields in the table.
DISPLAY Customermeans display all the fields in the table.- As each record is displayed, the display moves down a row to display the next Customer. The effect is more like what you would see in a report rather than a browse or other grid control.
- The block of code—everything from the
FOR EACHstatement through theENDstatement—iterates once for each Customer record (hence the syntaxFOR EACH). All the code in between (in this case just aDISPLAYstatement) is executed for each customer retrieved.- When the display gets to the bottom of the available display area, it automatically pauses, with a message prompting you to press the space bar to see the next set of rows.
- When you press the space bar, the display clears and a new set of rows appears.
- When Progress detects the end of the record set (all the Customer records in this case), it terminates the procedure with the message “Procedure complete. Press space bar to continue.”
- If you get tired of looking at customers (there are several hundred in the table), you can press the ESCAPE key to terminate the procedure.
|
Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |